
<template>
  <div class="shop-info" v-show="Object.keys(shop).length">
    <div class="info-top">
      <img :src="shop.logo" />
      <span>{{shop.name}}</span>
    </div>
    <div class="info-middle">
      <div class="info-middle-left">
        <div class="shop-sells">
          <p class="sells-count">{{shop.sells| sellCountFilter}}</p>
          <p class="sells-text">总销量</p>
        </div>
        <div class="shop-goods">
          <p class="goods-count">{{shop.goodsCount}}</p>
          <p class="goods-text">全部宝贝</p>
        </div>
      </div>
      <div class="info-middle-right">
        <table>
          <tr v-for='(v,i) in shop.score ' :key="i">
            <td>{{v.name}}</td>
            <td :class="[ v.isBetter ?  'score-more':'score']"> {{v.score}}</td>
            <td :class="[ v.isBetter ?  'better-more':'better']"> {{v.isBetter ?  '高':"低"  }}</td>
          </tr>
        </table>
      </div>
    </div>
    <div class="info-bottom">
      <p class="enter-shop">
        进店逛逛
      </p>
    </div>
  </div>
</template>

<script>
export default {
  name: 'detailShopInfo',

  props: {
    shop: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  filters: {
    sellCountFilter(val) {
      if (val > 10000) {
        val = (val / 10000).toFixed(1) + '万'
      }
      return val
    }
  }
}
</script>

<style scoped>
.shop-info {
  padding: 20px 8px 0;
  border-bottom: 5px solid #eee;
  font-size: 12px;
}
.info-top {
  display: flex;
  align-items: center;
  font-size: 16px;
}
.info-top img {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  margin-right: 5px;
  border: 2px solid rgba(100, 100, 100, 0.1);
}
.info-middle {
  display: flex;
  padding: 10px 0;
  text-align: center;
}
.info-middle > div {
  flex: auto;
  display: flex;
}
.info-middle-left {
  align-items: center;
  justify-content: space-evenly;
  border-right: 3px solid rgba(100, 100, 100, 0.1);
}
.sells-count,
.goods-count {
  font-size: 24px;
  margin-bottom: 10px;
}
.info-middle-right {
  justify-content: center;
}
.info-middle-right table {
  width: 120px;
}
.info-middle-right td {
  padding: 2px;
}
.score {
  color: green;
}
.score-more {
  color: red;
}
.better-more,
.better {
  color: #fff;
  background-color: green;
}
.better-more {
  background-color: red;
}
.info-bottom {
  text-align: center;
}
.enter-shop {
  display: inline-block;
  font-size: 18px;
  color: #eee;
  background-color: #999;
  width: 130px;
  line-height: 30px;
  border-radius: 30px;
  margin: 10px 0 20px;
}
</style>
